package com.xinke.module.system.mapper.oauth2;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.oauth2.OAuth2CodeDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.oauth2.*;

/**
 * OAuth2 授权码 Mapper
 *
 * @author yzx
 */
@Mapper
public interface OAuth2CodeMapper extends BaseMapperExt<OAuth2CodeDO> {

    default PageResult<OAuth2CodeDO> selectPage(OAuth2CodePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<OAuth2CodeDO>()
                .eqIfPresent(OAuth2CodeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OAuth2CodeDO::getUserType, reqVO.getUserType())
                .eqIfPresent(OAuth2CodeDO::getOauthCode, reqVO.getOauthCode())
                .eqIfPresent(OAuth2CodeDO::getClientNo, reqVO.getClientNo())
                .eqIfPresent(OAuth2CodeDO::getAuthScope, reqVO.getAuthScope())
                .betweenIfPresent(OAuth2CodeDO::getExpiresTime, reqVO.getExpiresTime())
                .eqIfPresent(OAuth2CodeDO::getRedirectUri, reqVO.getRedirectUri())
                .eqIfPresent(OAuth2CodeDO::getCodeState, reqVO.getCodeState())
                .orderByDesc(OAuth2CodeDO::getCodeId));
    }

}